package connexion;

import java.sql.*;

public class ConnexionExcel {
	
	private String path = "jdbc:odbc:source3";
	private String user = "";
	private String password = "";
	private Connection connection;
	
	
	public ConnexionExcel() {
		
	}
	
	public ConnexionExcel(String path, String user, String password) {
		this.path = path;
		this.user = user;
		this.password = password;
	}
	
	public Connection connect() {
		try {
			// Chargement du driver ODBC
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
			// Connexion à la base
			connection = DriverManager.getConnection(path, user,
					password);
		} catch (ClassNotFoundException e) {
			System.out.println("Problème avec le driver ODBC");
			return null;
		} catch (SQLException e) {
			System.out.println("Impossible de se connecter à la base");
			return null;
		}
		return connection;
	}
	
	public boolean disconnect() {
		try {
			connection.close();
			return true;
		} catch (SQLException e) {
			return false;
		}
	}
	
	/* note de la prof
	 * String request = "select [operation$].libelle";
	 */
}
